import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter);

// 组件
// 总体布局
const base = () => import("@/layout/Base");
// 首页
const index = () => import("@/page/dashboard/Index");
// 右边布局
const right = () => import("@/layout/Right");

// 内容管理
const article = () => import("@/page/content/Article"); // http://localhost:8080/#/article
const add = () => import("@/page/content/Add");
const comment = () => import("@/page/content/Comment");
const image = () => import("@/page/content/Image");
// 用户管理
const user = () => import("@/page/user/User");
const list = () => import("@/page/user/List");
const info = () => import("@/page/settings/Info");
const email = () => import("@/page/settings/Email");

// 运营
const category = () => import("@/page/operation/Category");
const loop = () => import("@/page/operation/Loop");
// 设置
const webSizeInfo = () => import("@/page/settings/Websize-info");
const friendLink = () => import("@/page/settings/Friend-link");

// 登录页面
const login = () => import("@/page/login/Login")

// 路由器
export const routes = [
    {
        path: '', // 注意这里路径为空
        component: base,
        redirect: '/index', // 路由重写向到首页
        children: [
            {
                path: '/index', // 首页
                name: '首页',
                icon: 'el-icon-s-home',
                hidden: false,
                requireLogin: false,
                component: index // http://localhost:8080/#/index
            },
            {
                path: '/content', // 右边内容布局  http://localhost:8080/#/content
                name: '内容管理',
                icon: 'el-icon-s-cooperation',
                hidden: false,
                component: right,
                children: [
                    {
                        path: 'add', // 注意这里没有加 / ,加 / 渲染不出页面  http://localhost:8080/#/content/add
                        name: '发表文章',
                        icon: 'el-icon-edit-outline',
                        hidden: false,
                        component: add
                    },
                    {
                        path: 'article',
                        hidden: false,
                        icon: 'el-icon-document',
                        name: '文章管理',
                        component: article // http://localhost:8080/#/content/article

                    },
                    {
                        path: 'comment',
                        hidden: false,
                        name: '评论管理',
                        icon: 'el-icon-chat-line-round',
                        component: comment  // http://localhost:8080/#/content/comment

                    },
                    {
                        path: 'image',  // http://localhost:8080/#/content/image
                        hidden: false,
                        name: '图片管理',
                        icon: 'el-icon-picture-outline',
                        component: image

                    }
                ]
            },
            {
                path: '/user', // 右边内容布局  http://localhost:8080/#/content
                name: '用户管理',
                icon: 'el-icon-user',
                hidden: false,
                component: right,
                children: [
                    {
                        path: 'list',
                        name: '用户列表',
                        hidden: false,
                        icon: 'el-icon-user',
                        component: list // http://localhost:8080/#/user/list

                    },
                    {
                        path: 'user', // 注意这里没有加 / ,加 / 渲染不出页面  http://localhost:8080/#/user/user
                        name: '用户管理',
                        hidden: false,
                        icon: 'el-icon-user',
                        component: user
                    }

                ]
            },
            {
                path: '/operation', // 右边内容布局  http://localhost:8080/#/content
                name: '运营管理',
                hidden: false,
                icon: 'el-icon-s-shop',
                component: right,   // 布局组件
                children: [
                    {
                        path: 'category', // 注意这里没有加 / ,加 / 渲染不出页面  http://localhost:8080/#/operation/category
                        hidden: false,
                        name: '分类管理',
                        icon: 'el-icon-s-grid',
                        component: category
                    },
                    {
                        path: 'loop',
                        hidden: false,
                        name: '轮播图管理',
                        icon: 'el-icon-picture-outline',
                        component: loop // httel-icon-picture-outline
                    }
                ]
            },
            {
                path: '/settings', // 右边内容布局  http://localhost:8080/#/content
                name: '网站设置',
                icon: 'el-icon-setting',
                hidden: false,
                component: right,   // 布局组件
                children: [
                    {
                        path: 'webSizeInfo', // 注意这里没有加 / ,加 / 渲染不出页面  http://localhost:8080/#/settings/webSizeInfo
                        hidden: false,
                        name: '网站信息',
                        icon: 'el-icon-setting',
                        component: webSizeInfo
                    },
                    {
                        path: 'friendLink',
                        hidden: false,
                        name: '友情链接',
                        icon: 'el-icon-paperclip',
                        component: friendLink // http://localhost:8080/#/settings/friendLink
                    },
                    {
                        path: 'info',
                        hidden: false,
                        name: '用户信息',
                        icon: 'el-icon-document',
                        component: info  // http://localhost:8080/#/settings/info

                    },
                    {
                        path: 'email',  // http://localhost:8080/#/settings/email
                        name: '设置邮箱',
                        hidden: false,
                        icon: 'el-icon-message',
                        component: email

                    }
                ]
            }
        ]
    },
    {
        path: '/login',
        component: login // http://localhost:8080/#/login
    }
]


const router = new VueRouter({
    // mode: 'history',  // 去掉路由URL中的#
    // base:'/',         // 去掉路由URL中的#
    routes // (缩写) 相当于 routes: routes
})

export default router;